﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[ExecuteInEditMode]
public class GPUImage : MonoBehaviour
{

    public Vector3 position {
        set
        {
            this.ChangePosition(value);
        }
    }

    public Vector3 rotation
    {
        set
        {
            this.ChangeRotation(value);
        }
    }

    public Vector3 scale
    {
        set
        {
            this.ChangeScale(value);
        }
    }

    private Material material;
    // Start is called before the first frame update
    void Start()
    {
        material = this.transform.GetComponent<Image>().material;
    }

    public void ChangePosition(Vector3 position)
    {
        if (material)
        {
            material.SetVector("_Position", position);
        }
    }

    public void ChangeRotation(Vector3 rotate)
    {
        if (material)
        {
            material.SetVector("_Rotation", rotate);
        }
    }

    public void ChangeScale(Vector3 scale)
    {
        if (material)
        {
            material.SetVector("_Scale", scale);
        }
    }


}
